package com.glsc.ngateway.common.base.domain.mysql.gateway.oaflow.xirtrade;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 衡泰xir指令同步记录表
 *
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_oa_flow_xir_trade_info set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_oa_flow_xir_trade_info set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_oa_flow_xir_trade_info")
public class TOaFlowXirTradeInfo extends BaseEntity {

    private static final long serialVersionUID = -3264094474527903316L;

    @Column(name = "deal_status", columnDefinition = "varchar(10) comment '业务状态'")
    private String dealStatus;

    @Column(name = "workflow_id", columnDefinition = "varchar(255) comment 'OA流程类型ID'")
    private String workflowId;

    @Column(name = "request_id", columnDefinition = "varchar(255) comment 'OA流程实例ID'")
    private String requestId;

    @Column(name = "request_title", columnDefinition = "varchar(1024) comment 'OA流程实例标题'")
    private String requestTitle;

    @Column(name = "intordid", columnDefinition = "varchar(20) comment '结算关联内部交易号'")
    private String intordid;

    @Column(name = "sysordid", columnDefinition = "varchar(20) comment '交易序号'")
    private String sysordid;

    @Column(name = "inst_id", columnDefinition = "varchar(10) comment '衡泰指令'")
    private String instId;

    @Column(name = "xir_biz_type", columnDefinition = "varchar(10) comment '衡泰业务类型'")
    private String xirBizType;

    @Column(name = "xir_biz_type_name", columnDefinition = "varchar(64) comment '衡泰业务类型（中文）'")
    private String xirBizTypeName;

    @Column(name = "cash_accid", columnDefinition = "varchar(64) comment '本方资金账户代码'")
    private String cashAccid;

    @Column(name = "secu_accid", columnDefinition = "varchar(64) comment '本方证券账户代码'")
    private String secuAccid;

    @Column(name = "party_id", columnDefinition = "int comment '对手方id'")
    private String partyId;

    @Column(name = "party_name", columnDefinition = "varchar(100) comment '对手方名称'")
    private String partyName;

    @Column(name = "party_bank_code", columnDefinition = "varchar(20) comment '对手方开户行行号'")
    private String partyBankCode;

    @Column(name = "party_bank_acc_name", columnDefinition = "varchar(50) comment '对手方开户行'")
    private String partyBankAccName;

    @Column(name = "party_acc_code", columnDefinition = "varchar(20) comment '对手方银行账号'")
    private String partyAccCode;

    @Column(name = "party_acc_name", columnDefinition = "varchar(100) comment '对手方户名'")
    private String partyAccName;

    @Column(name = "change_amount", columnDefinition = "decimal(21,4) comment '交易金额'")
    private BigDecimal changeAmount;

    @Column(name = "settle_begin_date", columnDefinition = "char(10) comment '首次结算日期'")
    private String settleBeginDate;

    @Column(name = "settle_end_date", columnDefinition = "char(10) comment '到期结算日期'")
    private String settleEndDate;

    @Column(name = "settle_days", columnDefinition = "int comment '借贷期限（天数）'")
    private Integer settleDays;

    @Column(name = "settle_fee_desc", columnDefinition = "varchar(100) comment '借贷费用描述'")
    private String settleFeeDesc;

    @Column(name = "settle_fee_rate", columnDefinition = "decimal(10,6) comment '借贷费率（如：0.23%）'")
    private BigDecimal settleFeeRate;

    @Column(name = "settle_fee_amount", columnDefinition = "decimal(21,4) comment '借贷费用'")
    private BigDecimal settleFeeAmount;

    @Column(name = "inst_id_first", columnDefinition = "varchar(255) comment '衡泰指令（首期）'")
    private String instIdFirst;

    @Column(name = "inst_id_end", columnDefinition = "varchar(255) comment '衡泰指令（到期）'")
    private String instIdEnd;

    @Column(name = "biz_brief", columnDefinition = "varchar(100) comment '交易摘要'")
    private String bizBrief;

    @Column(name = "dealer", columnDefinition = "varchar(20) comment '交易员'")
    private String dealer;

    @Column(name = "applicant", columnDefinition = "varchar(32) comment 'oa发起人'")
    private String applicant;

    @Column(name = "fj", columnDefinition = "varchar(2000) comment '附件'")
    private String fj;

    @Column(name = "dept_title", columnDefinition = "varchar(64) comment '部门'")
    private String deptTitle;

    @Column(name = "sync_time", columnDefinition = "datetime comment '更新时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime syncTime;
}
